<template>
  <div class="home">
    <div class="header">
      <div class="logo">
        <!-- <div class="img">
          <img src="./img/logo.png" alt="" />
        </div> -->
        三水智慧农污监测数据平台
      </div>

      <div class="list">
        <div
          v-for="(item, index) in list"
          class="list-detail"
          :class="{ active: $route.meta.navActive === item.value }"
          :key="index"
          @click="navClick(item.value)">
          <div class="icon">
            <Icon size="20" :type="item.icon" />
          </div>
          <div class="text">{{item.text}}</div>
        </div>
      </div>

      <div class="notice" @click="quitClick">
        <Icon
          size="26"
          color="black"
          type="md-power" />
      </div>
    </div>

    <div class="wrapper">
      <router-view />
    </div>
  </div>
</template>

<script>
import { telphoneStorageKey, userNameStorageKey } from 'common/js/config'
import { removeStorage } from 'common/js/utils'

export default {
  created () {
    this.initNav()
  },
  data () {
    return {
      list: [],
      matterList: []
    }
  },
  methods: {
    initNav () {
      const arr = [
        { icon: 'md-analytics', text: '实时监测', value: 'realtime' },
        { icon: 'md-barcode', text: '历史数据', value: 'history' },
      ]

      this.list = arr
    },
    navClick (value) {
      this.$router.push(`/home/${value}`)
    },
    quitClick () {
      removeStorage(telphoneStorageKey)
      removeStorage(userNameStorageKey)

      this.$router.push('/')
    },
  },
}
</script>

<style lang="scss">
@import 'common/scss/color';

.home {
  >.header {
    > .notice {
      .ivu-badge-count {
        background: $Color-primary !important;
      }
    }
  }
}
</style>

<style lang="scss" scoped>
@import 'common/scss/color';

.home {
  width: 100%;
  height: 100%;
  position: relative;
  > .header {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    background-color: white;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.5);
    padding: 0 15px;
    box-sizing: border-box;
    position: relative;
    z-index: 999;
    > .logo {
      flex: 0 0 320px;
      height: 100%;
      display: flex;
      align-items: center;
      overflow: hidden;
      cursor: pointer;
      font-size: 20px;
      color: $Color-primary;
      > .img {
        flex: 0 0 55px;
        height: calc(100% - 10px);
        text-align: center;
        margin-right: 3px;
        > img {
          height: 100%;
        }
      }
    }
    > .list {
      flex: 1;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      > .list-detail {
        flex: 0 0 130px;
        display: flex;
        align-items: center;
        cursor: pointer;
        &:nth-last-of-type(1) {
          flex: 0 0 120px;
        }
        > .icon {
          margin-right: 5px;
          > .ivu-icon {
            color: black;
          }
        }
        > .text {
          color: black;
          font-size: 16px;
        }
        &.active, &:hover {
          > .icon {
            > .ivu-icon {
              color: $Color-primary;
            }
          }
          > .text {
            color:  $Color-primary;
          }
        }
      }
    }
    > .notice {
      margin-right: 20px;
      cursor: pointer;
      &:hover {
        > .ivu-icon {
          color: lightgray !important;
        }
      }

    }
  }
  > .wrapper {
    width: 100%;
    height: calc(100% - 50px);
    position: relative;
  }
}
</style>
